package com.anhry.www.safety.manage.system.struts.inteceptor;

import java.util.Map;

import com.anhry.www.safety.manage.enterprise.bean.TbCorpInfo;
import com.anhry.www.safety.util.ContextPvd;
import com.anhry.www.safety.util.Util;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @date:Aug 20, 2012
 * @remark:
 * @author:dongbin
 */
public class CorpInterceptor extends AbstractInterceptor{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ContextPvd contextPvd;
	private String tip;
	public ContextPvd getContextPvd() {
		return contextPvd;
	}
	public void setContextPvd(ContextPvd contextPvd) {
		this.contextPvd = contextPvd;
	}
	public String getTip() {
		return tip;
	}
	public void setTip(String tip) {
		this.tip = tip;
	}
	
	public String intercept(ActionInvocation invocation) throws Exception {
		Map session = ActionContext.getContext().getSession();
		TbCorpInfo user = (TbCorpInfo)session.get(Util.SESSION_CORPUSER);
		if (user == null) {
			this.setTip("您长时间没有操作，请重新登录！");
			return "logout";
		} else {
			return invocation.invoke();
		}
	}
}

